package com.example.demo.service;

import com.example.demo.dao.CodeDao;
import com.example.demo.entity.CodeView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

@Service
public class CodeService {
    @Autowired
    private CodeDao codeDao;

    public int saveCode(CodeView code) {
        return codeDao.saveCode(code);
    }

    public List<CodeView> queryCode(CodeView code) {
        if (StringUtils.isEmpty(code.getTime())) {
            return new ArrayList<>();
        }
        return codeDao.queryCode(code);
    }

    public List<CodeView> queryList() {
        return codeDao.queryList();
    }

}
